Skip to content

fix(pretrends): seed NIS MVN integration and add tolerance to power_adequate - #921

Open
chenyangsu wants to merge 1 commit into
igerber:mainfrom
chenyangsu:fix/pretrends-nis-determinism
Open

chenyangsu wants to merge 1 commit into
igerber:mainfrom
chenyangsu:fix/pretrends-nis-determinism

Conversation

@chenyangsu

Copy link
Copy Markdown

Calling PreTrendsPower().fit(results) with M=None and pretest_form="nis" calls scipy.stats.multivariate_normal.cdf with unseeded QMC integration, so repeated calls return different MDV/power values (~1e-6 spread) and flip power_adequate between True and False at the MDV (12/20 True on a 10-period staggered panel).

Seeding the CDF call with np.random.default_rng(0) when SciPy accepts rng makes NIS calls deterministic, and using the 1e-5 abseps tolerance (1e-12 for Wald) in power_adequate keeps at-MDV results consistent, resolving the open TODO.md item. Happy to treat M=None as adequate by construction instead if you prefer.

Methodology references (required if estimator / math changes)

  • Method name(s): PreTrendsPower (NIS pretest power, Roth 2022)
  • Paper / source link(s): Roth (2022), https://doi.org/10.1257/aeri.20210236; TODO.md Actionable Backlog
  • Any intentional deviations from the source (and why): None; seeds SciPy's randomized Genz QMC integration and aligns power_adequate with its 1e-5 abseps tolerance.

Validation

  • Tests added/updated: Added TestNISDeterminismAndPowerAdequate in tests/test_pretrends.py (3 of 4 tests fail on main, all 4 pass here).
  • Backtest / simulation / notebook evidence (if applicable): tests/test_t07_pretrends_power_drift.py passes (13/13).

Security / privacy

  • Confirm no secrets/PII in this PR: Confirmed.

Changelog

  • changelog.d/ fragment added (or N/A - no user-visible change): changelog.d/20261126-pretrends-nis-determinism.md

Testing: pytest tests/test_pretrends.py tests/test_methodology_pretrends.py tests/test_pretrends_event_study.py tests/test_t07_pretrends_power_drift.py tests/test_design_event_study.py tests/test_changelog_fragments.py (339 passed, 2 deselected); pytest tests/test_base_estimator.py tests/test_diagnostic_report.py (407 passed, 13 skipped); ruff check, black --check, and mypy diff_diff pass with zero errors.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant